package com.cqie.secondhandtransaction.controller;

import com.cqie.secondhandtransaction.DTO.DataList;
import com.cqie.secondhandtransaction.entity.ProductInfo;
import com.cqie.secondhandtransaction.model.Result;
import com.cqie.secondhandtransaction.service.CollectShopInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 收藏的商品 前端控制器
 * </p>
 *
 * @author gdy
 * @since 2025-02-10
 */
@RestController
@RequestMapping("/collectShopInfo")
@Api(value = "收藏夹管理", tags = {"收藏夹管理"})
public class CollectShopInfoController extends BaseController{

    @Autowired
    private CollectShopInfoService collectShopInfoService;

    @GetMapping("/list")
    @ApiOperation(value = "获取收藏夹商品列表", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponse(code = 200, message = "ok", response = Result.class)
    public Result<DataList<ProductInfo>> getCollectShopList(){
        return response(collectShopInfoService.getCollectShopList());
    }

    @GetMapping("/add")
    @ApiOperation(value = "添加/取消 收藏", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponse(code = 200, message = "ok", response = Result.class)
    public Result<Void> addFavorites(@RequestParam Integer id){
        collectShopInfoService.addFavorites(id);
        return response();
    }

}
